gdksurface-win32.c: Fix Aerosnap computation
authorChun-wei Fan <fanchunwei@src.gnome.org>
Mon, 3 Aug 2020 08:01:40 +0000 (16:01 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Wed, 5 Aug 2020 07:38:08 +0000 (15:38 +0800)
Don't get the default display when we compute the Aerosnap region, but instead
get it from the underlying GdkSurface that we are using for the computation.

Also, don't unref the monitors that we obtain from the display in the wrong
place, which was why we had crashes whenever we triggered AeroSnap code (and we
are actually not supposed to do that as they are owned by the GdkDisplay that
is owned by the GdkSurface we are using), and this will eliminate lots of
criticals that are spewed as a result.

gdk/win32/gdksurface-win32.c

index fc52a82a5a7760397c4648464ea75cd2ce594926..ca8b765113875fe1d0f8da3a06cd82c7d9ec72f9 100644 (file)
@@ -1979,7 +1979,7 @@ calculate_aerosnap_regions (GdkW32DragMoveResizeContext *context)
   int i;
 #endif
 
-  display = gdk_display_get_default ();
+  display = gdk_surface_get_display (context->window);
   monitors = gdk_display_get_monitors (display);
 
 #define _M_UP 0
@@ -1999,7 +1999,6 @@ calculate_aerosnap_regions (GdkW32DragMoveResizeContext *context)
       GdkMonitor *monitor;
 
       monitor = g_list_model_get_item (monitors, monitor_idx);
-      g_object_unref (monitors);
       gdk_win32_monitor_get_workarea (monitor, &wa);
       gdk_monitor_get_geometry (monitor, &geometry);
 
@@ -3428,8 +3427,8 @@ setup_drag_move_resize_context (GdkSurface                   *window,
                                 GdkSurfaceEdge                edge,
                                 GdkDevice                   *device,
                                 int                          button,
-                                int                          x,
-                                int                          y,
+                                double                       x,
+                                double                       y,
                                 guint32                      timestamp)
 {
   RECT rect;